use serde::Deserialize;

#[derive(Deserialize, Debug)]
pub struct Food {
  /** 食物分类 0 卡路里 1 水 2 蛋白质 */
  pub category: u8,
  /** 快捷键 0 8 9 */
  pub key: u8,
  /** 使用时长 毫秒 */
  pub time: i32,
  /** 重复次数 */
  pub repeat: i32,
}

#[derive(Deserialize, Debug)]
pub struct Options {
  active: bool,
  pub foods: [Food; 3],
  pub shoe: i32,
  pub glove: i32,
}

impl Options {
  pub fn default() -> Self {
    Options {
      active: false,
      foods: [
        Food {
          category: 0,
          key: 8,
          time: 4000,
          repeat: 3,
        },
        Food {
          category: 2,
          key: 9,
          time: 11000,
          repeat: 2,
        },
        Food {
          category: 1,
          key: 0,
          time: 4000,
          repeat: 5,
        },
      ],
      shoe: 7,
      glove: 6,
    }
  }

  pub fn is_active(&self) -> bool {
    self.active
  }
}
